package cn.itcast.bos.utils;

import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.scheduling.quartz.AdaptableJobFactory;
import org.springframework.stereotype.Component;

@Component("MyJobFactory")
public class MyJobFactory extends AdaptableJobFactory {
	
	@Autowired
	private AutowireCapableBeanFactory mAutowireCapableBeanFactory;

	@Override
	protected Object createJobInstance(TriggerFiredBundle bundle)
			throws Exception {
		
		Object jobInstance = super.createJobInstance(bundle);
		mAutowireCapableBeanFactory.autowireBean(jobInstance);
		return jobInstance;
	}	
	
}
